package com.cskaoyan.gateway.controller.user;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.user.IVerifyService;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import com.mall.user.dto.UserVerifyRequest;
import com.mall.user.dto.UserVerifyResponse;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hanshuai
 * @version 1.0
 * @description 处理验证相关业务
 * @date 2021/12/11 22:22
 */
@RestController
@RequestMapping("user")
public class UserVerifyController {
    @Reference(timeout = 3000,retries = 2, check = false)
    IVerifyService iVerifyService;

    @RequestMapping("/verify")
    @Anoymous
    public ResponseData userVerify(UserVerifyRequest userVerifyRequest){
        UserVerifyResponse response = iVerifyService.verify(userVerifyRequest);
        if (!SysRetCodeConstants.SUCCESS.getCode().equals(response.getCode())){
            return new ResponseUtil().setErrorMsg(response.getMsg());
        }
        return new ResponseUtil().setData(null);
    }
}
